//
//  Man.h
//  NullablilityAnotationsDemo
//
//  Created by 李煜 on 2024/5/14.
//https://segmentfault.com/a/1190000023389150?utm_source=sf-related
//https://developer.apple.com/swift/blog/?id=25
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface Man : NSObject
//方法返回值修饰：
- (nullable NSString *)method;
//- (NSString * __nullable)method;
//- (NSString * _Nullable)method;

//声明属性的修饰：
@property (nonatomic, copy, nullable) NSString * aString;
//@property (nonatomic, copy) NSString * __nullable aString;
//@property (nonatomic, copy) NSString * _Nullable aString;

//方法参数修饰：
- (void)methodWithString:(nullable NSString *)aString;
//- (void)methodWithString:(NSString * _Nullable)aString;
//- (void)methodWithString:(NSString * __nullable)aString;

- (void)methodWithError:(NSError * _Nullable * _Nullable)error;
//- (void)methodWithError:(NSError * __nullable * __null_unspecified)error;
// 以及其他的组合方式
- (void)methodWithBlock:(nullable void (^)(void))block;
// 注意上面的 nullable 用于修饰方法传入的参数 Block 可以为空，而不是修饰 Block 返回值；
//- (void)methodWithBlock:(void (^ _Nullable)(void))block;
//- (void)methodWithBlock:(void (^ __nullable)(void))block;

//- (void)methodWithBlock:(nullable id __nonnull (^)(id __nullable params))block;
// 注意上面的 nullable 用于修饰方法传入的参数 Block 可以为空，而 __nonnull 用于修饰 Block 返回值 id 不能为空；
//- (void)methodWithBlock:(id __nonnull (^ __nullable)(id __nullable params))block;
//- (void)methodWithBlock:(id _Nonnull (^ _Nullable)(id _Nullable params))block;
// the method accepts a nullable block that returns a nonnull value
// there are some more combinations here, you get the idea
@end

NS_ASSUME_NONNULL_END
